﻿using System;
using Resources;

public partial class sparepartLeftInStock : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int sparepartId = GetSparepartId();

        pnlBody.Visible = sparepartId == 0 ? false : true;
        if (sparepartId == 0) return;


        new Utility().SetRowToDisplay(grdEquipments, Session["rowsToSDisplay"]);

        if (!IsPostBack)
            lblTotalEquipment.Text = "Total available spareparts in stock : " +
                                     new DirectService().GetAvailableSparepartsInStock().Rows.Count;

}
    public int GetSparepartId()
    {
        //if (!String.IsNullOrEmpty(Request.QueryString["workOrderId"])) return Int32.Parse(Request.QueryString["workOrderId"]);
        if (Session["informationId"] != null) return Int32.Parse(Session["informationId"].ToString());
        return 0;
    }
    protected void grdEquipment_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void grdEquipments_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
    {
        new Utility().SetSelectedColorToGridView(e, grdEquipments);
    }
    protected void odsSparepart_Selected(object sender, System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs e)
    {
        if (!new Utility().TestPermissions(Resource.PermissionSparepartLeft))
        {
            lblMessageValidate.Text = Resource.Permission;
            lblTotalEquipment.Visible = false;
            grdEquipments.Visible = false;
            return;
        }
    }
}
